package ;

//import flash.display.StageAlign;
//import flash.display.StageScaleMode;
//import flash.Lib;
#if neko
import neko.Lib;
#elseif flash
import flash.Lib;
#end
#if !flash
import org.zdc.io.SimpleIO;
import sys.io.File;
import sys.io.FileInput;
import org.zdc.io.ZPath;
#end

import fl.accessibility.AccImpl;
/**
 * ...
 * @author Simple Slime
 */
using Lambda;

class Main 
{
	var head = "E:/ZhangDongCai/ProgrameSource/haxe/svn/fl-haxe";
		
	//var paths:Array<String> = [
		//"fl.accessibility",
		//"fl.containers",
		//"fl.controls",
		//"fl.controls.dataGridClasses",
		//"fl.controls.listClasses",
		//"fl.controls.progressBarClasses",
		//"fl.core",
		//"fl.data",
		//"fl.events",
		//"fl.lang",
		//"fl.managers",
		//"fl.motion",
		//"fl.motion",
		//"fl.rsl",
		//"fl.transitions",
		//"fl.transitions",
		//"fl.video",
	//];
	
	static function main() 
	{
		//var stage = Lib.current.stage;
		//stage.scaleMode = StageScaleMode.NO_SCALE;
		//stage.align = StageAlign.TOP_LEFT;
		// entry point
		//SimpleIO.walkDir("E:/ZhangDongCai/ProgrameSource/haxe/svn/fl-haxe/src/fl", function(p:ZPath):Void {
			//renameType(p); 
		//}, 
		//0, 
		//ZPath.FILE_AND_DIRECTORY); 	
	}
	
	#if !flash
	private static function renameType(p:ZPath):Void {
		if (p.isDir) {
			return;
		}
		var content = File.getContent(p.fpath);
		//static const
		content = ~/\bstatic const\b/gi.replace(content, "static inline var");
		//Boolean
		content = ~/\bBoolean\b/gi.replace(content, "Bool");
		//Number
		content = ~/\bNumber\b/gi.replace(content, "Float");
		//int
		content = ~/\bint\b/gi.replace(content, "Int");
		//uint
		content = ~/\buint\b/gi.replace(content, "UInt");
		//Object
		content = ~/\bObject\b/gi.replace(content, "Dynamic");
		//Array
		content = ~/\bArray\b/gi.replace(content, "Array<Dynamic>");
		//void
		content = ~/\bvoid\b/gi.replace(content, "Void");
		//class
		content = ~/\bpublic class\b/gi.replace(content, "extern class");
		//protected
		content = ~/\bprotected \b/gim.replace(content, "");
		//function 
		//var regFunc = ~/\bfunction [\s\S]+?\{([\s\S]+?)\}/gim;		trace(regFunc);
		//if (regFunc.match(content)) {		
			//regFunc.replace(content, regFunc.matched(1));
		//}
		File.saveContent(p.fpath, content);
	}
	
	
	private static function renameHx(p:ZPath):Void {
		if (!p.isDir) {
			p.rename(p.fdir + "/" + p.name + ".hx");
		}
	}
	
	private static function makeFlFolders():Void {
		var head = "E:/ZhangDongCai/ProgrameSource/haxe/svn/fl-haxe";
		
		var paths:Array<String> = [
			"fl.accessibility",
			"fl.containers",
			"fl.controls",
			"fl.controls.dataGridClasses",
			"fl.controls.listClasses",
			"fl.controls.progressBarClasses",
			"fl.core",
			"fl.data",
			"fl.events",
			"fl.lang",
			"fl.managers",
			"fl.motion",
			"fl.rsl",
			"fl.transitions",
			"fl.video",
		];
		for (path in paths) {
			path = head + "/" + ~/\./gi.replace(path, "/");
			trace(path);
			SimpleIO.mkdir(path);
		}
	}
	#end
	
	private static function createFlClasses():Void {
		//var map:Dynamic = {
			//"fl.accessibility" : [	"AccImpl",
									//"ButtonAccImpl",
									//"CheckBoxAccImpl",
									//"ComboBoxAccImpl",
									//"DataGridAccImpl",
									//"LabelButtonAccImpl",
									//"ListAccImpl",
									//"RadioButtonAccImpl",
									//"SelectableListAccImpl",
									//"TileListAccImpl",
									//"UIComponentAccImpl", ],
									//
			//"fl.accessibility" 	: [	"BaseScrollPane",
									//"ScrollPane",
									//"UILoader", ],
									//
			//"fl.controls"		: [ "BaseButton",
									//"Button",
									//"ButtonLabelPlacement",
									//"CheckBox",
									//"ColorPicker",
									//"ComboBox",
									//"DataGrid",
									//"Label",
									//"LabelButton",
									//"List",
									//"NumericStepper",
									//"ProgressBar",
									//"ProgressBarDirection",
									//"ProgressBarMode",
									//"RadioButton",
									//"RadioButtonGroup",
									//"ScrollBar",
									//"ScrollBarDirection",
									//"ScrollPolicy",
									//"SelectableList",
									//"Slider",
									//"SliderDirection",
									//"TextArea",
									//"TextInput",
									//"TileList",
									//"UIScrollBar", ],
									//
			//"fl.containers"		: [	"BaseScrollPane",
									//"ScrollPane",
									//"UILoader", ],		
									//
			//"fl.controls.dataGridClasses" 		: [	"DataGridCellEditor",									
													//"DataGridColumn",									
													//"HeaderRenderer", ],
			//"fl.controls.listClasses"			: [  ],
			//"fl.controls.progressBarClasses",
			//"fl.core",
			//"fl.data",
			//"fl.events",
			//"fl.lang",
			//"fl.managers",
			//"fl.motion",
			//"fl.rsl",
			//"fl.transitions",
			//"fl.video"
		//}
	}
}